/*******************************************************************/
/* @ All Rights Reserved Copyright (C) 2014 broada,Co.,Ltd.        */
/*                                                                 */
/*  NAME      = t__create_listen.c                                 */
/*  NOTE      =                                                    */
/*  DATE      = 2014/12/03 by geyh                                 */
/*******************************************************************/

#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <CUnit/Basic.h>
#include <CUnit/CUnit.h>

#include "../comm/apmtest_cunit.h"
#include "frcomm.h"
#include "frmem.h"
#include "frcmd_server.h"

static int __suite_init(void)
{

	return 0;
}

static int __suite_cleanup(void)
{

	return 0;
}

int __create_listen(unsigned short us_port, int *p_listen_sock);


void case1(void)
{
    unsigned short us_port = 65535;
    int i_listen_sock = 0;
    int i_ret = 0;

    i_ret = __create_listen(us_port,&i_listen_sock);

    CU_ASSERT_EQUAL(i_ret,0);
    CU_ASSERT_NOT_EQUAL(i_listen_sock,0);

}

void case2(void)
{
    unsigned short us_port = 80;
    int i_listen_sock = 0;
    int i_ret = 0;

    i_ret = __create_listen(us_port,&i_listen_sock);

    CU_ASSERT_EQUAL(i_ret,1);

}

int add_suite()
{
	CU_pSuite pSuite = NULL;

	pSuite = CU_add_suite("t__create_listen 测试", __suite_init, __suite_cleanup);

	if (NULL == pSuite)
	{
		return 1;
	}


    //增加测试用例
   	CU_add_test(pSuite, "case1", case1);

    CU_add_test(pSuite, "case2", case2);

    return 0;

}

int main(int argc, char **argv)
{
    fr_slab_init(52428800, "test");
    run_cunit(add_suite);
    fr_slab_destroy();

    return 0;
}
